import request from '@/utils/request';

// 获取图片验证码
export function getCaptcha(uuid) {
  return request({
    url: '/auth/api/auth/captcha.jpg',
    method: 'get',
    responseType: "arraybuffer",
    params: {
      "uuid": uuid
    }
  })
}

// 登录
export function login(data) {
  return request({
    url: '/auth/api/auth/login',
    method: 'post',
    data
  })
}

// 登录
export function phoneLogin(data) {
  return request({
    url: '/auth/api/auth/phone_login',
    method: 'post',
    data
  })
}

// 退出登录
export function logout(userId) {
  return request({
    url: `/auth/api/auth/logout/${userId}`,
    method: 'get'
  })
}

// 获取AES前后端加解密的KEY和IV
export function getAesKeyAndIv(userId) {
  return request({
    url: `/auth/api/auth/getAesKeyAndIv`,
    method: 'get'
  })
}

// 获取用户角色信息
export function getRole(userId) {
  return request({
    url: `/user/api/role/getRoleInfoByUserId/${userId}`,
    method: 'get'
  })
}

// 获取所有的角色信息
export function getRoles(data = {}) {
  return request({
    url: `/user/role/roleList`,
    method: 'post',
    data
  })
}

// 创建角色信息
export function createRole(data = {}) {
  return request({
    url: `/user/role/create`,
    method: 'post',
    data
  })
}

// 编辑角色信息
export function editRole(data = {}) {
  return request({
    url: `/user/role/edit`,
    method: 'post',
    data
  })
}

// 删除角色信息
export function deleteRole(data = {}) {
  return request({
    url: `/user/role/delete`,
    method: 'post',
    data
  })
}

// 根据角色ID获取角色信息
export function getRoleById(roleId) {
  return request({
    url: `/user/role/getRoleById/${roleId}`,
    method: 'get'
  })
}






